void main(List<String> arguments) {
  (String, int) record1;
  record1 = ('A string', 123);
  ({int a, bool b}) record2;
  record2 = (a: 123, b: true);
  ({int a, int b}) recordAB = (a: 1, b: 2);
  ({int x, int y}) recordXY = (x: 3, y: 4);
  (int a, int b) record_AB = (1, 2);
  (int x, int y) record_XY = (3, 4);
  record_AB = record_XY;
  var record = ('first', a: 2, b: true, 'last');
  print(record.$1);
  print(record.a);
  print(record.b);
  print(record.$2);
  (num, Object) pair = (42, 'a');
  var first = pair.$1;
  var second = pair.$2;
  (int x, int y, int z) point = (1, 2, 3);
  (int r, int g, int b) color = (1, 2, 3);
  print(point == color);
  ({int x, int y, int z}) point1 = (x: 1, y: 2, z: 3);
  ({int r, int g, int b}) color1 = (r: 1, g: 2, b: 3);
  print(point1 == color1);
  final json = <String, dynamic>{'name': 'Dash', 'age': 10, 'color': 'blue'};
  var (name, age) = userInfo(json);
  /*Equivalent to:
  var info = userInfo(json);
  var name = info.$1;
  var age = info.$2;
  */
  var list1 = [1, 2, 3];
  var list2 = ['Car', 'Boat', 'Plane'];
  assert(list1.length == 3);
  assert(list1[1] == 2);
  list1[1] = 1;
  var constantList = const [1, 2, 3];
  var halogens = {'fluorine', 'chlorine', 'bromine', 'iodine', 'astatine'};
  var names = <String>{};
  //Set<String> names = {}; //This works, too.
  //var names = {}; //Creates a map, not a set.
  var elements = <String>{};
  elements.add('fluorine');
  elements.addAll(halogens);
  assert(elements.length == 5);
  final constantSet = const {
    'fluorine',
    'chlorine',
    'bromine',
    'iodine',
    'astatine',
  };
  var gifts = {
    //Key    //Value
    'first': 'partridge',
    'second': 'turtledoves',
    'fifth': 'golden rings',
  };
  var nobleGases = {2: 'helium', 10: 'neon', 18: 'argon'};
  var gift = Map<String, String>();
  gift['first'] = 'partridge';
  gift['second'] = 'turtledoves';
  gift['fifth'] = 'golden rings';
  var nobleGase = Map<int, String>();
  nobleGase[2] = 'helium';
  nobleGase[10] = 'neon';
  nobleGase[18] = 'argon';
  gifts['fourth'] = 'calling birds';
  assert(gifts['first'] == 'partridge');
  assert(gifts['sixth'] == null);
  assert(gifts.length == 4);
  final constantMap = const {2: 'helium', 10: 'neon', 18: 'argon'};
  var list = [1, 2, 3];
  var list_2 = [0, ...list];
  assert(list_2.length == 4);
  var list__2 = [0, ...?list];
  assert(list__2.length == 4);
  var nav1 = ['Home', 'Furniture', 'Plants', 'Outlet'];
  var nav2 = ['Home', 'Furniture', 'Plants', 'Inventory'];
  var listOfInts = [1, 2, 3];
  var listOfStrings = ['#0', for (var i in listOfInts) '#$i'];
  assert(listOfStrings[1] == '#1');
  var Names = <String>['Seth', 'Kathy', 'Lars'];
  var uniqueNames = <String>{'Seth', 'Kathy', 'Lars'};
  var pages = <String, String>{
    'index.html': 'Homepage',
    'robots.txt': 'Hints for web robots',
    'humans.txt': 'We are people, not machines',
  };
  var nameSet = Set<String>.of(Names);
  var names_1 = <String>[];
  names_1.addAll(['Seth', 'Kathy', 'Lars']);
  print(names_1 is List<String>);
  var someBaseClassFoo = Foo<SomeBaseClass>();
  var extenderFoo = Foo<Extender>();
  var foo = Foo();
  print(foo);
  var useIt = compareAndOffset(A(), A());
  IntList i1 = [1, 2, 3];
  Map<String, List<String>> m1 = {};
  ListMapper<String> m2 = {};
  assert(sort is Compare<int>);
}

(String name, int age) userInfo(Map<String, dynamic> json) {
  return (json['name'] as String, json['age'] as int);
}

final buttons = [
  (label: "Button I", onPressed: () => print("Action -> Button I")),
  (label: "Button II", onPressed: () => print("Action -> Button II")),
];

class ButtonItem {
  final String label;
  final void Function()? onPressed;
  ButtonItem({required this.label, required this.onPressed});
  bool get hasOnPressed => onPressed != null;
}

extension type Buttonitem._(({String label, void Function()? onPressed}) _) {
  String get label => _.label;
  void Function()? get onPressed => _.onPressed;
  Buttonitem({required String label, void Function()? onPressed})
    : this._((label: label, onPressed: onPressed));
  bool get hasOnPressed => _.onPressed != null;
}

final List<ButtonItem> Buttons = [
  ButtonItem(label: "Button I", onPressed: () => print("Action -> Button I")),
  ButtonItem(label: "Button II", onPressed: () => print("Action -> Button II")),
];

abstract class ObjectCache {
  Object getByKey(String key);
  void setByKey(String key, Object value);
}

abstract class StringCache {
  String getByKey(String key);
  void setByKey(String key, String value);
}

abstract class Cache<T> {
  T getByKey(String key);
  void setByKey(String key, T value);
}

class Foo<T extends Object> {
  String toString() => "Instance of Foo<$T>";
}

class SomeBaseClass {}

class Extender {}

abstract interface class Comparable<T> {
  int compareTo(T o);
}

int compareAndOffset<T extends Comparable<T>>(T t1, T t2) =>
    t1.compareTo(t2) + 1;

class A implements Comparable<A> {
  @override
  int compareTo(A other) => 0;
}

T first<T>(List<T> ts) {
  T tmp = ts[0];
  return tmp;
}

typedef IntList = List<int>;
typedef ListMapper<X> = Map<X, List<X>>;
typedef Compare<T> = int Function(T a, T b);
int sort(int a, int b) => a - b;
